package com.ruoyi.logistic.service.impl;


import com.github.pagehelper.PageHelper;
import com.ruoyi.logistic.domain.NetworkCustomerFreightCollect;
import com.ruoyi.logistic.domain.PageDate;
import com.ruoyi.logistic.domain.vo.NetworkCustomerFreightCollectVo;
import com.ruoyi.logistic.mapper.NetworkCustomerFreightCollectMapper;
import com.ruoyi.logistic.service.NetworkCustomerFreightCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class NetworkCustomerFreightCollectServiceImpl implements NetworkCustomerFreightCollectService {
    @Autowired
    private NetworkCustomerFreightCollectMapper networkCustomerFreightCollectMapper;

    @Override
    public List<NetworkCustomerFreightCollect> search(NetworkCustomerFreightCollectVo networkCustomerFreightCollectVo) {
        PageHelper.startPage(networkCustomerFreightCollectVo.getPageDate());
        List<NetworkCustomerFreightCollect> collectList = networkCustomerFreightCollectMapper.search(networkCustomerFreightCollectVo);
        if (collectList!= null){
            for (NetworkCustomerFreightCollect collect : collectList){
                if (networkCustomerFreightCollectVo.getCollectType() == 1){
                    collect.setCollectTime(networkCustomerFreightCollectVo.getStartTime() + "至" + networkCustomerFreightCollectVo.getEndTime());
                }else {
                    collect.setCollectTime(networkCustomerFreightCollectVo.getMonth());
                }
            }
        }
        return collectList;
    }
}
